﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Workflow.Runtime.Tracking;
using System.Configuration;
using BneyBaruch.Ingest.MorningLesson.Workflow;
using BneyBaruch.Ingest.Core.ServiceModel;
using BneyBaruch.Ingest.Core.WorkflowCommunication.Tracking;
using System.ServiceModel;

namespace BneyBaruch.Ingest.WorkflowMonitor
{
    public partial class frmWorkflowMonitor : Form
    {
        #region Constants

        private const string WorkflowTrackingServiceEndpoint = "WorkflowTrackingServiceEndpoint";

        #endregion

        #region Fields

        private DuplexServiceProxy<IWorkflowTrackingService> workflowTrackingService;
        private IWorkflowTrackingServiceCallback workflowTrackingServiceCallback = null;

        #endregion

        #region Constructors

        public frmWorkflowMonitor()
        {
            InitializeComponent();
            workflowTrackingServiceCallback = new WorkflowTrackingServiceCallback(this);
            workflowTrackingService = new DuplexServiceProxy<IWorkflowTrackingService>(
                new InstanceContext(workflowTrackingServiceCallback),
                WorkflowTrackingServiceEndpoint
            );
            workflowTrackingService.Proxy.SubscribeToWorkflowTrackingEvents();
        }

        #endregion

        #region Form Load

        private void frmWorkflowMonitor_Load(object sender, EventArgs e)
        {
            notifyIcon1.Text = "Workflow Monitor Started";
            notifyIcon1.ShowBalloonTip(5000, notifyIcon1.BalloonTipTitle, "Workflow Monitor Started", ToolTipIcon.Info);
        }

        #endregion
    }
}
